using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Utility;
using Entities;

public partial class Admin_Suatourmo : System.Web.UI.Page
{
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loaddropdownlist();
            LoadData();

        }
    }
    private void loaddropdownlist()
    {
        dr_tent.DataSource = tbTourBUS.GetAll();
        dr_tent.DataTextField = tbTourCollumn.tentour.ToString();
        dr_tent.DataValueField = tbTourCollumn.matour.ToString();
        dr_tent.DataBind();
        dr_tent.Items.Insert(0, new ListItem("All", "0"));
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_matm.Text = id.ToString();

            tbTourmo  tourm = tbTourmoBUS .GetByID(id);
            
            dr_tent.SelectedValue = tourm.Matour .ToString();
            txt_nm .Text = tourm.Ngaymo .ToString ();
           
            txt_nkh .Text = tourm.Ngaykhoihanh .ToString();
         


        }
        catch
        {
            Response.Redirect("~/Admin/Danhsachtourmo.aspx");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        tbTourmo  tm = tbTourmoBUS .GetByID(id);

        tm.Matour = int.Parse(dr_tent.SelectedValue);
        tm.Ngaymo = DateTime.Parse(txt_nm.Text);
        tm.Ngaykhoihanh = DateTime.Parse(txt_nkh.Text);
        tbTourmoBUS .Update(tm);

    //    catch
    //    {
        Response.Redirect("~/Admin/Danhsachtourmo.aspx");
    //    }
       
    }
}
